<%@ include file="/WEB-INF/pages/common/taglibs.jsp" %>
<%@ include file="/WEB-INF/pages/common/checkpermission.jsp" %>
<script type="text/javascript">
    function saveRecord() {
        var currentForm = document.forms["editForm"];
        currentForm.elements["userModel.userName"].value = currentForm.elements["userModel.userName"].value.trim();
        currentForm.elements["userModel.userPassword"].value = currentForm.elements["userModel.userPassword"].value.trim();
        if(isEmpty(currentForm.elements["userModel.userName"].value)){
            alert('<s:text name="label.user.required"/>');
            return;
        }
        if(isEmpty(currentForm.elements["userModel.userPassword"].value)){
            alert('<s:text name="label.password.required"/>');
            return;            
        }
        if(isEmpty(currentForm.elements["userModel.confirmPassword"].value)){
        	alert('<s:text name="label.confirm.password.empty"/>');
            return;
        }
        if(currentForm.elements["userModel.userPassword"].value!=currentForm.elements["userModel.confirmPassword"].value){
            alert('<s:text name="label.password.different"/>');
            return;
        }
        submitForm("editForm", "save.action");
    }

    function cancelRecord() {
            submitForm("editForm", "search.action");
    }    
</script>

<s:form name="editForm" action="">

    <table align="center" cellpadding="0" cellspacing="0" class="body_content full_width">
        <tr>
            <td align="left" valign="bottom" class="main_page_content_icon" width="4%">
                <img src='<c:url value="/images/body-icon_check.gif"/>' width="29" height="44">
            </td>
            <td valign="bottom" class="page_title_bg" width="96%">
                <span class="page_title">
                    <s:text name="label.update.user"/>
                </span>
            </td>
        </tr>
        <tr>
            <td class="subcontent" colspan="2">&nbsp;</td>
        </tr>
    </table>


    <table border="0" align="center" cellpadding="0" cellspacing="0" class="body_content full_width bordered">
        <tr class="even">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.userId"/></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:property value="userModel.userId"/>
                <s:hidden name="userModel.userId"/>
            </td>
        </tr>
        <tr class="odd">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.userName"/></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:textfield name="userModel.userName" maxLength="25" cssStyle="width:180px"/>
            </td>
        </tr>
        <tr class="even">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.userPassword"/></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:password name="userModel.userPassword" maxLength="25" cssStyle="width:180px"/>
            </td>
        </tr>
        <tr class="odd">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.confirm.password"/></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:password name="userModel.confirmPassword" maxLength="25" cssStyle="width:180px"/>
            </td>
        </tr>
        <tr class="even">
            <td class="form_label_padded" width="10%" nowrap><s:text name="label.userRole"/></td>
            <td class="form_label_padded" width="2%">:</td>
            <td class="txtData" align="left">
                <s:select list="roleList" name="userModel.userRole" listKey="value" listValue="label"/>
            </td>
        </tr>
        <tr class="odd">
            <td class="txtData" colspan="3">
                <input type="button" class="button" value="<s:text name='label.save'/>" onclick="saveRecord();">
                <input type="button" class="button" value="<s:text name='label.back'/>" onclick="cancelRecord();">               
            </td>
        </tr>
    </table>
</s:form>



